package org.web.daotest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.web.ssm.dao.OrderDetailMapper;
import org.web.ssm.dao.UserMapper;
import org.web.ssm.model.OrderDetail;
import org.web.ssm.model.wechatModel.Statis;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by LUOLIANG on 2016/6/13.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:configs/spring-mybatis.xml"})
public class orderdao {
    private Logger logger = LogManager.getLogger(orderdao.class);
    @Autowired
    private OrderDetailMapper orderDetailMapper;
    @Autowired
    private UserMapper userMapper;

//    @Test
//    public void testquery() {
//        List<OrderDetail> list = orderDetailMapper.selectAllByUser("23", "day");
//
//        logger.info("查询结果：" + list);
//    }

    @Test
    public void testinsert() {
//        OrderDetail orderDetail = new OrderDetail(userMapper.selectByPrimaryKey(String.valueOf(23)), "123", "1234", "1234", 122d, new Date());
//
//        int res = orderDetailMapper.insertOrder(orderDetail);
//        if (res == 1) {
//            logger.info("插入一行成功：" + orderDetail.toString());
//        }
        List<Statis> list = orderDetailMapper.selectSumBytime("23", "mon");
        System.out.println(list);
    }
}
